<template>
  <div class="page_body">
    <HomeTop :topTitle="topTitle"></HomeTop>
    <div class="myHonor_body">
      <img src="../../assets/image/honor_top01.png" class="myHonor_body_top" />
      <div>
        <mt-navbar v-model="selected">
          <mt-tab-item id="1">
            <div style="font-size: 0.36rem">会员</div>
          </mt-tab-item>
          <mt-tab-item id="2"
            ><div style="font-size: 0.36rem">证书</div>
          </mt-tab-item>
        </mt-navbar>
        <mt-tab-container v-model="selected" :swipeable="swipeable">
          <mt-tab-container-item id="1">
            <div class="myHonor_list">
              <div
                class="myHonor_list_item vip_item"
                v-if="sourceType != 2 && honorsData.is_referee_vip == 1"
              >
                <img
                  class="myHonor_list_item_icon"
                  src="../../assets/image/honor_icon01.png"
                />
                <div class="myHonor_list_name">上海市篮球协会个人会员</div>
              </div>
              <div
                class="myHonor_list_item"
                v-if="sourceType != 2 && honorsData.is_referee_vip == 2"
              >
                <img
                  class="myHonor_list_item_icon"
                  src="../../assets/image/honor_icon04.png"
                />
                <div class="myHonor_list_name">上海市篮球协会个人会员</div>
              </div>

              <div
                class="myHonor_list_item referee_item"
                v-if="sourceType != 2 && honorsData.is_referee == 1"
              >
                <img
                  class="myHonor_list_item_icon"
                  src="../../assets/image/honor_icon02.png"
                />
                <div class="myHonor_list_name">上海市篮球协会注册裁判员</div>
              </div>
              <div
                class="myHonor_list_item"
                v-if="sourceType != 2 && honorsData.is_referee == 2"
              >
                <img
                  class="myHonor_list_item_icon"
                  src="../../assets/image/honor_icon04.png"
                />
                <div class="myHonor_list_name">上海市篮球协会注册裁判员</div>
              </div>

              <div
                class="myHonor_list_item coach_item"
                v-if="sourceType != 3 && honorsData.is_coach == 1"
              >
                <img
                  class="myHonor_list_item_icon"
                  src="../../assets/image/honor_icon02.png"
                />
                <div class="myHonor_list_name">上海市篮球协会注册教练员</div>
              </div>
              <div
                class="myHonor_list_item"
                v-if="sourceType != 3 && honorsData.is_coach == 2"
              >
                <img
                  class="myHonor_list_item_icon"
                  src="../../assets/image/honor_icon04.png"
                />
                <div class="myHonor_list_name">上海市篮球协会注册教练员</div>
              </div>
            </div>
          </mt-tab-container-item>
          <mt-tab-container-item id="2"></mt-tab-container-item>
        </mt-tab-container>
      </div>
    </div>
  </div>
</template>
<style src="../../assets/css/user/myHonor.css" scoped></style>

<script>
import HomeTop from "@/components/homeTop.vue";
import { Toast } from "mint-ui";

export default {
  name: "MyHonor",
  components: {
    HomeTop,
  },
  data() {
    return {
      topTitle: "我的荣誉", // 顶部组件参数设置
      source: "", // 来源
      sourceType: 1, // 来源类型; 1. 总个人中心; 2. 教练员; 3. 裁判员
      honorsData: {
        is_referee_vip: "", // 会员注册
        referee_vip_date: "", // 会员注册时间
        is_referee: "", // 裁判员注册
        referee_date: "", // 裁判员注册时间
        is_coach: "", // 教练员注册
        coach_date: "", // 教练员注册时间
      },
      swipeable: true, // tab切换动画开启
      selected: "1", // tab选中值
    };
  },
  created: function () {
    let query = this.$route.query;

    if (query.source != undefined && query.source != "") {
      this.source = query.source;
    }

    let coachIndex = this.source.indexOf("coach");
    let refereeIndex = this.source.indexOf("referee");

    if (coachIndex == 0) {
      this.sourceType = 2;
    } else if (refereeIndex == 0) {
      this.sourceType = 3;
    } else {
      this.sourceType = 1;
    }
    this.getUserDataFn();
  },
  methods: {
    // 查询列表数据
    getUserDataFn: function () {
      let that = this;
      let url = "/mobile/myHonor";
      let data = {};
      this.axios
        .post(url, data)
        .then((response) => {
          if (response.code == 0) {
            that.honorsData = response.info;
          } else {
            Toast({
              message: response.msg,
              duration: 3000,
            });
          }
        })
        .catch(function (error) {
          console.log(error);
        });
    },
  },
};
</script>
